package com.example.demo.enums;

import com.example.demo.model.BookInfo;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.ibatis.annotations.Delete;
import org.springframework.web.bind.annotation.GetMapping;

@AllArgsConstructor
public enum StatusEnum {
    DELETED( 0, "无效"),
    NORMAL(1, "可借阅"),
    FORBIDDEN(2, "不可借阅"),
    ;
    @Getter
    private int code;
    @Getter
    private String name;
    public static StatusEnum getNameByCode(int code){
       switch (code){
           case 1:
               return NORMAL;
           case 2:
               return FORBIDDEN;
           case 0:
               return DELETED;
       }
//       for (StatusEnum statusEnum : StatusEnum.values() ) {
//            if(statusEnum.getCode()==code){
//                return statusEnum;
//            }
//        }
       return null;



    }
//    for(StatusEnum statusEnum: StatusEnum.values()){
////            if (statusEnum.getCode()==code){
////                return statusEnum;
////            }
////        }
////        return null;


}
